home *** CD-ROM | disk | FTP | other *** search
- #include <iostream.h>
- #include <assert.h>
- #include <stdio.h>
-
- main ()
- {
- char ch;
- int i;
-
- cout << "\nMaking filebuf streams fout and fin...";
- filebuf foutbuf;
- foutbuf.open("ffile", ios::out);
- ostream fout(&foutbuf);
- assert(fout.good());
- assert(fout.is_open());
- assert(fout.writable());
- assert(!fout.readable());
- fout << "This file has one line testing output streams.\n";
- fout.close();
- assert(!fout.is_open());
- filebuf finbuf;
- finbuf.open("ffile", ios::in);
- istream fin(&finbuf);
- assert(fin.good());
- assert(fin.is_open());
- assert(!fin.writable());
- assert(fin.readable());
- cout << "contents of file:\n";
-
- do
- {
- i = ((fin >> ch) ? 1 : 0);
- fprintf(stderr, "i is %d\n", i);
- if(!i)
- break;
- cout << ch;
- } while(1);
-
- fin.close();
- assert(!fin.is_open());
- }
-